package mae.app;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

/**
 * The class for the MainActivity
 * 
 * @author Dennis Stepp
 * @version 1.0z Build 1 June 7, 2011
 * 
 */
public class MainMenuActvity extends ListActivity {

	static final ListItemActivities[] collections = {
			new ListItemActivities("Depression Glass", DepressionGlass.class),
			new ListItemActivities("Bosco Peanut Butter Cups", Boscul.class),
			new ListItemActivities("Super Hero Cups", Superhero.class) };
	TextView selection;

	/**
	 *  Called when the activity is first created. Gives the ListAdapter
	 *  a layout defined in XML, and array of Items which populate this layout */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setListAdapter(new ArrayAdapter<ListItemActivities>(this,
				android.R.layout.simple_list_item_1, collections));
		selection = (TextView) findViewById(R.id.selection);
	}

	/**
	 * Provides a means to reach the Activity classes that match
	 *  the selections position.
	 */
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		final Intent intent = new Intent(this,
				collections[position].getActivity());
		startActivityForResult(intent, position);
	}
}
